package network.tcp.bio;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @program: baseModule
 * @description:
 * @author: zhanghz001
 * @create: 2020-10-27 04:03
 **/
public class TcUploadServer {
    public static void main(String[] args) {
        server();
    }

    private static void server() {
        try (ServerSocket socket = new ServerSocket(9000);
        ) {
            ThreadPoolExecutor pool = (ThreadPoolExecutor) Executors.newCachedThreadPool();

            while (true) {
                Socket accept = socket.accept();
                pool.submit(new ThreadSocket(accept));
            }
            // pool.shutdown();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {

        }

    }
}
